#include "..\..\LunarLib\include\LunarWin32.h"
#include "..\..\LunarLib\include\L3DEngine.h"
#include "d3d.h"

#pragma comment (lib, "LunarWin32.lib")

MyWin32* pMain = NULL;
MyD3D*  pMyd3d = NULL;
MSG			msg;

int Processmsg()
{
	 while( msg.message != WM_QUIT )
	 {
		 if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
		 {
			 TranslateMessage( &msg );
			 DispatchMessage( &msg );
		 }
		else
			pMyd3d->Render();
	}
	return msg.wParam;
}


int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	HWND  hWnd;

	pMain = new MyWin32();
	pMyd3d = new MyD3D();
	pMain->Create(1, 800, 600, "Direct3D9 Example 3rd - Transform");
	hWnd = pMain->GetMyWinHandle();
	
	if (!hWnd )
		return E_FAIL;
	if (FAILED (pMyd3d->InitD3D( hWnd ) ) )
		return E_FAIL;
	if (FAILED (pMyd3d->InitVB() ) )
		return E_FAIL;
	
	Processmsg();
	
	delete pMyd3d;
	delete pMain;
}

